<template>
  <div class="fsc-sidebar" :class="!isTimeSlot&&isTimeTitle?'fsc-sidebar-on':''">
    <div class="sb-wrap">
      <div
        class="sb-hide-icon"
        :class="!sidebardata.sidebarHide?'':'sb-show-icon'"
        :title="!sidebardata.sidebarHide?'收起':'展开'"
        @click="sbhide"
      ><i class="el-icon-d-arrow-right"></i></div>
      <div class="sb-wrap-box">
        <div class="sb-title" v-if="isTimeTitle" :style="barHeightStyle">{{sidebardata.title}}</div>
        <div class="sb-time" v-if="isTimeSlot">
          <div class="sb-time-col" v-for="(item, index) in sidebardata.timegather" :key="index" :style="{height: item.heightpx}">{{item.time}}</div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    sidebardata: {
      type: Object,
      default() {
        return {
          title: '上午班',
          timegather: []
        }
      }
    },
    isTimeTitle: {
      type: Boolean,
      default: false
    },
    isTimeSlot: {
      type: Boolean,
      default: false
    },
    rowHeight: {
      type: Number,
      default: 64
    }
  },
  data() {
    return {
      barHeight: {
        height: '0px'
      }
    }
  },
  watch: {
    sidebardata(data) {
      this.calBarHeight(data)
    }
  },
  methods: {
    calBarHeight(data) {
      if (data && typeof data === 'object') {
        this.barHeightStyle = {
          height: data.barHeight + 'px'
        }
      }
    },
    sbhide() {
      this.$emit('sidebarHideChange')
    }
  }
}
</script>

<style lang="scss" scoped>
@import '~@/styles/fullschedule.scss';

.sb-wrap{
  position: relative;
  border-bottom: solid 1px $borderColor;
  &:last-child{
    border: none;
  }
  .sb-hide-icon{
    font-size: 18px;
    color: #ccc;
    position: absolute;
    left: 0;
    top: 0;
    z-index: 2;
    transform: rotate(-135deg);
    cursor: pointer;
    &:hover{
      color: #333;
    }
  }
  .sb-show-icon{
    transform: rotate(45deg);
  }
  .sb-wrap-box{
    background-color: #fff;
    display: flex;
    flex-wrap: nowrap;
    .sb-title{
      display: flex;
      border-right: solid 1px $borderColor;
      align-items: center;
      padding:10px;
      text-align: center;
    }
    .sb-time{
      width: 100%;
      .sb-time-col{
        display: flex;
        justify-content: center;
        align-items: center;
        text-align: center;
        border-bottom: solid 1px $borderColor;
        &:last-child{
          border: none;
        }
      }
    }
  }
}
.fsc-sidebar-on{
  display: flex;
  width: 100%;
  flex-wrap: wrap;
  justify-content: center;
  align-content:center;
  box-sizing: border-box;
  .sb-wrap-box{
    display: flex;
    // align-content: center;
    // justify-content: center;
    width: 100%;
    .sb-title{
      width:100%;
      border-right: none;
      justify-content: center;
    }
  }
}
</style>
